     .ORIG x1200
;save R4 and R3
     ADD R6,R6,#-2
     STW R3,R6,#0
     ADD R6,R6,#-2
     STW R4,R6,#0
;load pte at base address  
     LEA R3, U
     LDW R3,R3,#0
;load counter
     LEA R4, Y
     LDW R4,R4,#0
;load reference bit mask
     LEA R5,R
     LDW R5,R5,#0
;clear reference bit of pte
next AND R7,R7,#0
     LDW R7,R3,#0
     AND R7,R7,R5
     STW R7,R3,#0
;increment counter to next pte
     ADD R3,R3,#2
     ADD R4,R4,#-1
     BRp next

;done now restore R4 and R3 and returmn
     LDW R4,R6,#0
     ADD R6,R6,#2
     LDW R3,R6,#0
     ADD R6,R6,#2
;return
     RTI

U    .FILL x1000
Y    .FILL #128
R    .FILL xFFFE

     .END
